/**
 * 付款申请单
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){
    console.log('------$scope.menuId1-----', $scope.menuId);
    console.log('------$scope.buttonArr1-----', $scope.buttonArr);

    $scope.bindBtn = function(event) {
        var datas = $scope.getSelectedRows();
        switch(event){
            case 'event-to-add':
            {
                window.top.add_tab("付款申请单 - 新增","/web/finance/tcwPaymentApply/toAdd");
                break;
            }
            case 'event-to-export'://导出
            {
                $scope.doExport('/api/inter/tcwPaymentApply/export');
                break;
            }

            case 'event-to-exportdy':
            {
                if(datas.length == 0) {
                    layer.alert('尚未选中数据');
                } else if(datas.length > 1) {
                    layer.alert('只能选中一行数据');
                } else {
                    $http.post('/api/inter/tcwPaymentApply/exportdy', {}, {params: {bid:datas[0].bid}})
                        .success(function (data) {
                            if (data.code == 0) {
                                if (data.msg != undefined && data.msg.startsWith('http')) {
                                    window.open(data.msg);
                                } else {
                                    layer.msg(data.msg);
                                }
                            } else {
                                alert(data.msg);
                            }
                        })
                        .error(function(result){
                            layer.close();
                            layer.msg("操作失败，请稍后再试！", {icon: 2});
                        });
                }
                break;
            }


        };
    }
}

//表格双击
app.controller('dbClickCtrl', ['$scope', '$http', DbClickController]);
function DbClickController($scope, $http){
    $scope.doubleClick = function(data) {
        window.top.add_tab('付款申请单 - 编辑','/web/finance/tcwPaymentApply/toEdit?bid=' + data.bid);
    }
}


